package com.ruoyi.service.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.service.domain.ServiceCombo;
import com.ruoyi.service.service.IServiceComboService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 服务套餐Controller
 * 
 * @author ZDL
 * @date 2024-10-21
 */
@RestController
@RequestMapping("/service/combo")
public class ServiceComboController extends BaseController
{
    @Autowired
    private IServiceComboService serviceComboService;

    /**
     * 查询服务套餐列表
     */
    @PreAuthorize("@ss.hasPermi('service:combo:list')")
    @GetMapping("/list")
    public TableDataInfo list(ServiceCombo serviceCombo)
    {
        startPage();
        List<ServiceCombo> list = serviceComboService.selectServiceComboList(serviceCombo);
        return getDataTable(list);
    }

    /**
     * 导出服务套餐列表
     */
    @PreAuthorize("@ss.hasPermi('service:combo:export')")
    @Log(title = "服务套餐", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ServiceCombo serviceCombo)
    {
        List<ServiceCombo> list = serviceComboService.selectServiceComboList(serviceCombo);
        ExcelUtil<ServiceCombo> util = new ExcelUtil<ServiceCombo>(ServiceCombo.class);
        util.exportExcel(response, list, "服务套餐数据");
    }

    /**
     * 获取服务套餐详细信息
     */
    @PreAuthorize("@ss.hasPermi('service:combo:query')")
    @GetMapping(value = "/{comboId}")
    public AjaxResult getInfo(@PathVariable("comboId") Long comboId)
    {
        return success(serviceComboService.selectServiceComboByComboId(comboId));
    }

    /**
     * 新增服务套餐
     */
    @PreAuthorize("@ss.hasPermi('service:combo:add')")
    @Log(title = "服务套餐", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ServiceCombo serviceCombo)
    {
        return toAjax(serviceComboService.insertServiceCombo(serviceCombo));
    }

    /**
     * 修改服务套餐
     */
    @PreAuthorize("@ss.hasPermi('service:combo:edit')")
    @Log(title = "服务套餐", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ServiceCombo serviceCombo)
    {
        return toAjax(serviceComboService.updateServiceCombo(serviceCombo));
    }

    /**
     * 删除服务套餐
     */
    @PreAuthorize("@ss.hasPermi('service:combo:remove')")
    @Log(title = "服务套餐", businessType = BusinessType.DELETE)
	@DeleteMapping("/{comboIds}")
    public AjaxResult remove(@PathVariable Long[] comboIds)
    {
        return toAjax(serviceComboService.deleteServiceComboByComboIds(comboIds));
    }
}
